<?php
/**
 * 初始化APP
 * 初始化数据库,语系
 */
class Initial {
	public $css_path;
	public $script_path;
	public $image_path;
	public $lang;
	public $database;
	public $config;
	public  $ci;
	
	/**
	 * 自动选择数据库链接
	 */
	public function init(){
		$suport_langs = array('zh-cn','zh-tw','en');
		$langs = explode(';',preg_replace('/q=0\.[1-9]{1},*/i', '', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
		
		$site_lang = 'zh-cn';
// 		if (count($langs)){
// 			foreach ($langs as $key=>$lang){
// 				list($accept_lang, $lang_serie) = explode(',', $lang);
// 				if (in_array($accept_lang, $suport_langs)){
// 					$site_lang = $accept_lang;
// 					break;
// 				}
// 			}
// 		}

		define('SITE_LANG', $site_lang);
		//导入语系配置
		$this->config = new CI_Config();
		$this->config->load(SITE_LANG.'/config');
	}
}